Package edu.claflin.finder.logic.comp
Class EdgeWeightComparator
- java.lang.Object
-
- edu.claflin.finder.logic.comp.EdgeWeightComparator
-
- All Implemented Interfaces:
java.util.Comparator<Edge>
public class EdgeWeightComparator extends java.lang.Object implements java.util.Comparator<Edge>
A simple edge weight comparator in which the edge data is considered a numeric value and used as the comparison benchmark.- Version:
- 3.0 February 4, 2016
- Author:
- Charles Allen Schultz II
-
-
Field Summary
Fields Modifier and Type Field Description private booleanascendingIndicates if the comparator should sort elements in ascending order.
-
Constructor Summary
Constructors Constructor Description EdgeWeightComparator(boolean ascending)Constructs an EdgeWeightComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(Edge o1, Edge o2)Compares the edges based on the D data held by the edge.private java.math.BigDecimaltoNumber(java.lang.Object object)Converts an unknown object into a BigDecimal if possible.
-
-
-
Method Detail
-
compare
public int compare(Edge o1, Edge o2)
Compares the edges based on the D data held by the edge. Assumes the data is a numeric value.- Specified by:
comparein interfacejava.util.Comparator<Edge>- Parameters:
o1- the first edge to compare.o2- the second edge to compare.- Returns:
- -1, 0, or 1 if the first edge is ordered before, the same as, or after the second.
-
toNumber
private java.math.BigDecimal toNumber(java.lang.Object object)
Converts an unknown object into a BigDecimal if possible.- Parameters:
object- the Object to convert.- Returns:
- the converted BigDecimal object.
-
-